import * as actionTypes from '../constants/index';
import axios from 'axios'

// const removeBlackById = (data) => {
//   return {
//     type: actionTypes.REMOVE_BLACK_BY_ID,
//     data
//   }
// };
const saveBlacklist = (data) => {
  return {
    type: actionTypes.GET_BLACK_LIST,
    data
  }
};

const saveKeyword = (data) => {
  return {
    type: actionTypes.GET_KEYWORD,
    data
  }
};

const showModal = (data) => {
  return {
    type: actionTypes.SHOW_MODAL,
    data
  }
};


const hideModal = (data) => {
  return {
    type: actionTypes.HIDE_MODAL,
    data
  }
};

const fetchBlacklist = () => {
  return async dispatch => {
    let res = await
      axios.post('vrv-monitor-platform-web/blacklist/queryByOrgCode')
    if(res.data.statusCode===200){
      dispatch(saveBlacklist(res.data.data))
    }
  }
};

const fetchKeywordlist = (params = {}) => {
  return async dispatch => {
    let res = await
      axios.post('vrv-monitor-platform-web/moniterkey/query',{
        ...params
      })
    if(res.data.statusCode===200){
      dispatch(saveKeyword(res.data.data))
    }
  }
};

export {saveBlacklist, fetchBlacklist,showModal,hideModal,saveKeyword,fetchKeywordlist};
